home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / nwqms.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  34KB  |  1,150 lines

  1. {$X+,B-,V-} {essential compiler directives}
  2.  
  3. UNIT nwQMS;
  4.  
  5. { nwQMS unit as of 950301 / NwTP 0.6 API. (c) 1993,1995, R. Spronk }
  6. { Based in part on a unit containing queue services routines, written by
  7.   Erik van Heyningen in April 1994. }
  8.  
  9. INTERFACE
  10.  
  11. Uses nwMisc;
  12.  
  13. { Function:                             Interrupt:  Comments:
  14.  
  15.   Queue Server Functions:
  16.  
  17. . AbortServicingQueueJob                (F217/73)   (S)
  18. . AttachQueueServerToQueue              (F217/6F)   (S)
  19. . ChangeToClientRights                  (F217/74)   (S)
  20. . DetachQueueServerFromQueue            (F217/70)   (S)
  21. . FinishServicingQueueJob               (F217/72)   (S)
  22. . RestoreQueueServerRights              (F217/75)   (S)
  23. . ServiceQueueJob                       (F217/71)   (S)
  24. . SetQueueServerStatus                  (F217/77)   (S)
  25.  
  26.   Queue Operator Functions:
  27.  
  28. . ChangeQueueJobPosition                (F217/6E)   (O)
  29. * CreateQueue                           (F217/64)   (SUP)
  30. * DestroyQueue                          (F217/65)   (SUP)
  31. . SetQueueStatus                        (F217/67)   (O)
  32.  
  33.   Queue User Functions:
  34.  
  35. . CreateQueueJob                        (F217/68)   (C)
  36. . StartQueueJob                         (F217/69)   (C)        (1)
  37.  
  38.   Miscellaneous Queue Functions:
  39.  
  40. . ChangeQueueJobEntry                   (F217/6D)   (C-O)
  41. * GetQueueJobList                       (F217/6B)   (C-O)
  42. * GetQueueJobsFileSize                  (F217/78)   (C-O-S)
  43. * ReadQueueStatus                       (F217/66)   (C-O)
  44. * ReadQueueJobEntry                     (F217/6C)   (C-O-S)
  45. . ReadQueueServerStatus                 (F217/76)   (C-O)
  46. * RemoveJobFromQueue                    (F217/6A)   (C-O)
  47.  
  48.  
  49. Notes: C  : Function available to Clients (Queue Users);
  50.        S  : Function available to Servers (Queue Servers);
  51.        O  : Functions availaible to Operators (Queue Operators);
  52.        SUP: Functions available to Supervisors/Workgroup managers.
  53.  
  54.        (1): StartQueueJob is a.k.a. CloseFileAndStartQueueJob
  55. }
  56.  
  57. CONST { Queue status flag }
  58.       QS_ALL_OK              = $00;
  59.       QS_CANT_ADD_JOBS       = $01; { possibility to add jobs disabled by operator }
  60.       QS_SERVERS_CANT_ATTACH = $02; { attachment of servers to queue disabled by operator }
  61.       QS_CANT_SERVICE_JOBS   = $04; { queue halted by operator }
  62.        { QS_XXXX constants can be ORed to form a QstatusFlag }
  63.  
  64.       QF_NONE                = $00;
  65.       QF_AUTO_START          = $08;
  66.       QF_SERVICE_RESTART     = $10;
  67.       QF_ENTRY_OPEN          = $20;
  68.       QF_USER_HOLD           = $40;
  69.       QF_OPERATOR_HOLD       = $80;
  70.  
  71. CONST MaxQueueJobs = 250;
  72.  
  73. Type TQueueStatus= RECORD
  74.                    ObjectId               : Longint; { Object id of queue                         }
  75.                    Status                 : Byte;    { status of queue QS_XXX }
  76.                    NbrOfJobs              : Byte;    { Number of jobs in queue                   }
  77.                    NbrOfServers           : Byte;    { Number of servers attached to queue       }
  78.                    ServerObjectIds        : array[1..25] of Longint;
  79.                      { List of Objects-ids of attached servers            }
  80.                    ServerConnNbrs         : array[1..25] of Byte;
  81.                      { List of attached server stations                   }
  82.                    MaxNbrOfServers        : Byte; { ??? }
  83.                    end;
  84.  
  85.      TQueueServerStatus= Array[1..64] of Byte;
  86.                          { undefined structure -as far as QMS is concerned-}
  87.  
  88. Type TJobNumberList = Array[1..MaxQueueJobs] OF Word;
  89.      TQueueJobList  = record
  90.                       JobCount   : Word;
  91.                       JobNbrs    : TJobNumberList; { List of jobs numbers by position in queue }
  92.                       MaxJobs    : Word;    {????}    { Maximum job numbers              }
  93.                       end;
  94.  
  95.      TJobFileHandle=Array[1..6] of Byte;
  96.      TQueueJobEntry =Record  { Unit external Type }
  97.                      ClientConnNbr          : Byte;
  98.                      ClientTaskNbr          : Byte;
  99.                      ClientObjectID         : Longint;
  100.                      JobEntryTime           : TnovTime;
  101.                      JobNumber              : Word;
  102.                      JobFileName            : String[14];
  103.                      JobFileHandle          : TjobFileHandle;
  104.  
  105.                      TargetServerIDnumber   : Longint;     {2}
  106.                      TargetExecutionTime    : TnovTime;    {2}
  107.                      JobType                : Word;        {2}
  108.                      JobControlFlags        : Byte;        {2}
  109.                      JobDescription         : String[50];  {2}
  110.                      ClientRecordArea       : Array[1..152] OF Byte; {2}
  111.  
  112.                      JobPosition            : Byte;        {2/operators only}
  113.  
  114.                      ServerConnNbr,                        {1}
  115.                      ServerTaskNbr          : Byte;        {1}
  116.                      ServerObjectID         : Longint;     {1}
  117.                      End;
  118.        { 1: Filled by Queue server. As long as ServerTaskNbr=0,
  119.             queue entry is not being serviced.
  120.          2: Can be changed by queue operators and/or the 'owner' of
  121.             the job after job has been placed in queue
  122.        }
  123.  
  124. Var result:Word;
  125.  
  126. {F217/64 {2.1x+}
  127. Function CreateQueue(Qname     :string; QobjectType:Word;
  128.                      dirHandle :Byte;   pathName   :string;
  129.                      VAR QobjID:Longint                      ):Boolean;
  130. { Creates an object of an object_queue_type in the bindery, checks that
  131.   all settings are valid before creating. Returns the object_id of the
  132.   created queue if creation was successfull. }
  133.  
  134. {F217/65 [2.1x+]}
  135. Function DestroyQueue(QobjID:Longint):Boolean;
  136. { Destroys the specified Queue; aborts all jobs in the queue;
  137.   associated files/directories are deleted;
  138.   queue object is removed from the bindery. }
  139.  
  140.  
  141. {F217/76 [2.1x/3.x]}
  142. Function ReadQueueStatus(QobjID:Longint;
  143.                          Var Qstatus:TQueueStatus):Boolean;
  144. { Read the status of a queue. This information is changed by queueservers.}
  145.  
  146. {F217/67 [2.1x+]}
  147. Function SetQueueStatus(QobjId:Longint; NewQstatusFlag:Byte):Boolean;
  148. { Change the queue status flag. Use the QS_XXXX constants }
  149.  
  150. {F217/6B}
  151. FUNCTION GetQueueJobList( QueueObjId: Longint;
  152.                           Var QJobList:TQueueJobList): Boolean;
  153. { You need to be either a Q_USER or a Q_OPERATOR }
  154.  
  155. {F217/6C}
  156. FUNCTION ReadQueueJobEntry( QObjId: Longint;JobNbr: Word;
  157.                             VAR QJob: TQueueJobEntry): Boolean;
  158. { You need to be either a Q_USER, Q_OPERATOR or a Q_SERVER }
  159.  
  160. {F217/6A}
  161. FUNCTION RemoveJobFromQueue( QObjId: Longint; JobNbr: Word): Boolean;
  162. { You need to be Q_OPERATOR or the Q_USER who queued the job }
  163.  
  164. {F217/69 [2.1x+]}
  165. Function StartQueueJob(QobjId:Longint;JobNbr:Word):Boolean;
  166.  
  167.  
  168. {F217/6E [2.1x+]}
  169. Function ChangeQueueJobPosition(QobjId:Longint; JobNbr:Word;
  170.                                 NewJobPos:Byte              ):Boolean;
  171. { Q_OPERATOR only }
  172.  
  173.  
  174. {F217/6F [2.1x+]}
  175. Function AttachQueueServerToQueue(QobjId:Longint):Boolean;
  176. { Q_SERVERs only }
  177.  
  178.  
  179. {F217/70 [2.1x+]}
  180. Function DetachQueueServerFromQueue(QobjId:Longint):Boolean;
  181. { Q_SERVERs only }
  182.  
  183.  
  184. {F217/71 [2.1x+]}
  185. Function ServiceQueueJob(QobjID:Longint; JobType:Word;
  186.                                     Var QjobEntry:TQueueJobEntry):Boolean;
  187. { Q_SERVERs only }
  188.  
  189. {F217/72 [2.1x+]}
  190. Function FinishServicingQueueJob(QobjId:Longint;JobNbr:Word;
  191.                                  Charge:Longint             ):Boolean;
  192. { Q_SERVERs only }
  193.  
  194. {F217/73 [2.1x+]}
  195. Function AbortServicingQueueJob(QobjId:Longint; JobNbr:Word):Boolean;
  196.  
  197. {F217/74 [2.1x+]}
  198. Function ChangeToClientRights(QobjId:Longint;JobNbr:Word):Boolean;
  199. { Q_SERVERs servicing job only }
  200.  
  201. {F217/75 [2.1x+]}
  202. Function RestoreQueueServerRights:Boolean;
  203. { Q_SERVERs, servicing job and having previously called
  204.   ChangeToClientRights only }
  205.  
  206. {F217/76 [2.1x+]}
  207. Function ReadQueueServerStatus(QobjId        :Longint;
  208.                                QserverObjId  :Longint;
  209.                                QserverConnNbr:Byte;
  210.                            Var Qstatus:TQueueServerStatus):Boolean;
  211.  
  212.  
  213. {F217/77 [2.1x+]}
  214. Function SetQueueServerStatus(QobjId:Longint; Qstatus:TqueueServerStatus):Boolean;
  215.  
  216. {F217/78 [2.1x+]}
  217. Function GetQueueJobsFileSize(QobjId:Longint; JobNbr:Word;
  218.                              Var JobSize:Longint          ):Boolean;
  219.  
  220. {F217/68 [2.1x+]}
  221. Function CreateQueueJob(QobjId:Longint;
  222.               {i/o} Var Qjob:TqueueJobEntry):Boolean;
  223.  
  224. {F217/6D [2.1x+]}
  225. Function ChangeQueueJobEntry(QobjId:Longint;Qjob:TQueueJobEntry):Boolean;
  226.  
  227. IMPLEMENTATION {============================================================}
  228.  
  229. Uses nwIntr;
  230.  
  231. Type TIntJobStruct =Record  { Unit internal Type }
  232.                  _ClientConnNbr,
  233.                  _ClientTaskNbr           : Byte;
  234.                  _ClientObjectID,            {hi-lo}
  235.                  _TargetServerIDnumber : Longint;      {hi-lo}
  236.                  _TargetExecutionTime,
  237.                  _JobEntryTime         : Array[1..6] OF Byte; { YMDHMS }
  238.                  _JobNumber,                           {hi-lo}
  239.                  _JobType              : Word;         {hi-lo}
  240.                  _JobPosition,
  241.                  _JobControlFlags      : Byte;
  242.                  _JobFileName          : Array[1..14] OF CHAR; { ASCIIZ }
  243.                  _JobFileHandle        : TJobFileHandle;
  244.                  _ServerConnNbr,
  245.                  _ServerTaskNbr        : Byte;
  246.                  _ServerObjectID       : Longint;       {hi-lo}
  247.                  _JobDescription       : Array[1..50] OF CHAR; { ASCIIZ }
  248.                  _ClientRecordArea     : Array[1..152] OF Byte
  249.                  End;
  250.  
  251. Procedure ConvertQJE2ext(qje:TintJobStruct;VAR ext:TQueueJobEntry;
  252.                          Unrestricted:Boolean);
  253. {convert the internal QueueJobEntry type into the equivalent
  254.  unit external type }
  255. begin
  256. With qje,ext
  257.  do begin
  258.     ClientConnNbr:=_ClientConnNbr;
  259.     ClientTaskNbr:=_ClientTaskNbr;
  260.     ClientObjectId:=Lswap(_ClientObjectId);
  261.     Move(_JobEntryTime,JobEntryTime,6); JobEntryTime.DayOfWeek:=0;
  262.     { # fix year for year 2000+ ? }
  263.     JobNumber:=swap(_JobNumber);
  264.     ZstrCopy(JobFileName,_JobFileName,14);
  265.     JobFileHandle:=_JobFileHandle;
  266.     TargetServerIdNumber:=Lswap(_TargetServerIdNumber);
  267.     Move(_TargetExecutionTime,TargetExecutionTime,6); TargetExecutionTime.DayOfWeek:=0;
  268.     { # fix year for year 2000+ ? }
  269.     JobType:=swap(_JobType);
  270.     JobControlFlags:=_JobControlFlags;
  271.     IF UnRestricted
  272.      then begin
  273.           ZstrCopy(JobDescription,_JobDescription,50);
  274.           Move(_ClientRecordArea,ClientRecordArea,152);
  275.           end;
  276.     JobPosition:=_JobPosition;
  277.     ServerConnNbr:=_ServerConnNbr;
  278.     ServerTaskNbr:=_ServerTaskNbr;
  279.     ServerObjectId:=Lswap(_ServerObjectId);
  280.     end;
  281. end;
  282.  
  283. Procedure ConvertQJE2int(qje:TQueueJobEntry;VAR int:TintJobStruct);
  284. {convert the external QueueJobEntry type into the equivalent
  285.  unit internal type }
  286. Var s:string[50];
  287. begin
  288. With qje,int
  289.  do begin
  290.     _ClientConnNbr:=ClientConnNbr;
  291.     _ClientTaskNbr:=ClientTaskNbr;
  292.     _ClientObjectId:=Lswap(ClientObjectId);
  293.     _TargetServerIdNumber:=Lswap(TargetServerIdNumber);
  294.     Move(TargetExecutionTime,_TargetExecutionTime,6);
  295.     { # fix year for year 2000+ ? }
  296.     Move(JobEntryTime,_JobEntryTime,6);
  297.     { # fix year for year 2000+ ? }
  298.     _JobNumber:=swap(JobNumber);
  299.     _JobType:=swap(JobType);
  300.     _JobPosition:=JobPosition;
  301.     _JobControlFlags:=JobControlFlags;
  302.     PStrCopy(s,JobFilename,14);Move(s[1],_JobFileName,14);
  303.     _JobFileHandle:=JobFileHandle;
  304.     _ServerConnNbr:=ServerConnNbr;
  305.     _ServerTaskNbr:=ServerTaskNbr;
  306.     _ServerObjectId:=Lswap(ServerObjectId);
  307.     PstrCopy(s,JobDescription,50);Move(s[1],_JobDescription,50);
  308.     Move(ClientRecordArea,_ClientRecordArea,152);
  309.     end;
  310. end;
  311.  
  312.  
  313. {--- Initial Functions, create and destroy Job Queue --------------------}
  314.  
  315. {F217/64 {2.1x+}
  316. Function CreateQueue(Qname     :string; QobjectType:Word;
  317.                      dirHandle :Byte;   pathName   :string;
  318.                      VAR QobjID:Longint                      ):Boolean;
  319. { Creates an object of an object_queue_type in the bindery, checks that
  320.   all settings are valid before creating. Returns the object_id of the
  321.   created queue if creation was successfull. }
  322. { QobjectType= OT_PRINT_QUEUE, OT_JOB_QUEUE,
  323.                OT_ARCHIVE_QUEUE, own obj.type >$8000 }
  324. { You need supervisor-equivalent or workgroup-manager rights to perform
  325.   this action. }
  326. { To add (remove) Queue operators or
  327.   (dis-)allow Queue servers to attach to a queue or
  328.   (dis-)allow objects (users/groups) to use a queue,
  329.   use the AddBinderyObjectToSet and DeleteBinderyObjectFromSet functions
  330.   in the nwBindry unit with the property names Q_OPERATORS, Q_SERVERS
  331.   and Q_USERS respectively. }
  332. Type Treq=record
  333.           len       :Word;
  334.           subFunc   :Byte;
  335.           _Qtype    :Word; { hi-lo}
  336.           _QdivData :array[1..168] of Byte;
  337.           end;
  338.      Trep=record
  339.           _Qid:Longint; {hi-lo}
  340.           end;
  341.      TPreq=^Treq;
  342.      TPrep=^Trep;
  343. Var i:Byte;
  344. Begin
  345. WITH TPreq(GlobalReqBuf)^
  346.  do begin
  347.     subFunc:=$64;
  348.     _Qtype:=swap(QobjectType); { force hi-lo }
  349.     i:=ord(Qname[0])+1;
  350.     UpString(Qname);Move(Qname[0],_QdivData[1],i);
  351.  
  352.     inc(i);
  353.     _QdivData[i]:=DirHandle;
  354.  
  355.     inc(i);
  356.     UpString(PathName);
  357.     Move(PathName[0],_QDivData[i],ord(PathName[0])+1);
  358.  
  359.     len:=3+i+ord(PathName[0]);
  360.     F2SystemCall($17,len+2,SizeOf(Trep),result);
  361.     end;
  362. With TPrep(GlobalReplyBuf)^
  363.  do begin
  364.     QobjID:=Lswap(_Qid); { force lo-hi }
  365.     end;
  366. CreateQueue:=(result=0)
  367. { resultcodes: $00 Success ; $96 Server Out Of Memory; $99 Drectory Full;
  368.                $9B Bad Directory Handle; $9C Invalid Path; $ED Property Already Exists;
  369.                $EE Object Already Exists; $EF Invalid Name; $F0 Wildcard Not Allowed;
  370.                $F1 Invalid Bindery Security; $F5 No Object Create Privilege;
  371.                $F7 No Property Create Privilege; $FC No Such Object;
  372.                $FE Server Bindery Locked; $FF Bindery Failure. }
  373. end;
  374.  
  375. {F217/65 [2.1x+]}
  376. Function DestroyQueue(QobjID:Longint):Boolean;
  377. { Destroys the specified Queue; aborts all jobs in the queue;
  378.   associated files/directories are deleted;
  379.   queue object is removed from the bindery. }
  380. Type Treq=record
  381.           len:Word;
  382.           subFunc:Byte;
  383.           _QobjID:Longint; {hi-lo}
  384.           end;
  385.      TPreq=^Treq;
  386. Begin
  387. WITH TPreq(GlobalReqBuf)^
  388.  do begin
  389.     len:=SizeOf(Treq)-2;
  390.     subFunc:=$65;
  391.     _QobjID:=Lswap(QobjID); { force hi-lo }
  392.     end;
  393. F2SystemCall($17,Sizeof(Treq),0,result);
  394. DestroyQueue:=(result=0);
  395. { resultcodes: $00 Success ; $96 Server Out Of Memory; $9C Invalid Path;
  396.                $D0 Queue Error; $D1 No Queue; $FF Hardware Failure. }
  397. end;
  398.  
  399. {----------------Client or Diagnostic Functions-----------------------------}
  400.  
  401. {F217/76 [2.1x/3.x]}
  402. Function ReadQueueStatus(QobjID:Longint;
  403.                          Var Qstatus:TQueueStatus):Boolean;
  404. { Read the status of a queue. This information is changed by queueservers.}
  405. Type Treq=record
  406.           len    :Word;
  407.           subFunc:Byte;
  408.           _QobjID:Longint; {hi-lo}
  409.           end;
  410.      Trep=record
  411.           _QobjID:Longint; {hi-lo}
  412.           _Qstatus:Byte;
  413.           _NbrOfJobs:Byte;
  414.           _NbrOfServers:Byte;    {max.25}
  415.           _serverIDlist:array[1..25] of Longint; {hi-lo}
  416.           _ServerConnNbrs:array[1..25] of Byte;
  417.           _MaxNumberOfServers:Byte;
  418.           end;
  419.      TPreq=^Treq;
  420.      TPrep=^Trep;
  421. Var t:Byte;
  422. Begin
  423. WITH TPreq(GlobalReqBuf)^
  424.  do begin
  425.     len:=SizeOf(Treq)-2;
  426.     subFunc:=$66;
  427.     _QobjID:=Lswap(QobjID); {force hi-lo}
  428.     end;
  429. F2SystemCall($17,Sizeof(Treq),SizeOf(Trep),result);
  430. With Qstatus, TPrep(GlobalReplyBuf)^
  431.  do begin
  432.     ObjectId:=Lswap(_QobjId);
  433.     status:=_Qstatus;
  434.     NbrOfJobs:=_NbrOfJobs;
  435.     NbrOfServers:=_NbrOfServers;
  436.  
  437.     for t:=1 to NbrOfServers
  438.      do ServerObjectIDs[t]:=Lswap(_ServerIDlist[t]);
  439.     Move(_ServerConnNbrs,ServerConnNbrs,25);
  440.     MaxNbrOfServers:=_MaxNumberOfServers;
  441.     end;
  442. ReadQueueStatus:=(result=0)
  443. end;
  444.  
  445. {F217/67 [2.1x+]}
  446. Function SetQueueStatus(QobjId:Longint; NewQstatusFlag:Byte):Boolean;
  447. { Change the queue status flag. Use the QS_XXXX constants }
  448. Type Treq=record
  449.           len:Word;
  450.           subFunc:Byte;
  451.           _QobjId:Longint; {hi-lo}
  452.           _Qstatus:Byte;
  453.           end;
  454.      TPreq=^Treq;
  455. Begin
  456. WITH TPreq(GlobalReqBuf)^
  457.  do begin
  458.     subFunc:=$67;
  459.     _QobjId:=Lswap(QobjId);
  460.     _Qstatus:=NewQStatusFlag;
  461.     len:=SizeOf(Treq)-2;
  462.     end;
  463. F2SystemCall($17,SizeOf(Treq),0,result);
  464. SetQueueStatus:=(result=0)
  465. { Valid completion codes:
  466.   $00 Success
  467.   $96 Server Out Of Memory;
  468.   $9C Invalid Path;
  469.   $D0 Queue Error;
  470.   $D1 No Queue;
  471.   $D3 No Queue Rights;
  472.   $FE Server Bindery Locked;
  473.   $FF Bindery Failure.
  474. }
  475. end;
  476.  
  477.  
  478.  
  479. {F217/6B}
  480. FUNCTION GetQueueJobList( QueueObjId: Longint;
  481.                           Var QJobList:TQueueJobList): Boolean;
  482. { You need to be either a Q_USER or a Q_OPERATOR }
  483. Type TReq=Record
  484.           BufLen     : Word;
  485.           func       : Byte;
  486.           _QueueObjId: Longint; {hi-lo}
  487.           end;
  488.      TRep=Record
  489.           _JobCount:Word; {max 250, hi-lo}
  490.           _JobBuf  :TJobNumberList; {array, entries hi-lo}
  491.           _MaxJobs :Word; {hi-lo}
  492.           End;
  493.      TPrep=^Trep;
  494.      TPreq=^Treq;
  495. Var i:Word;
  496. Begin
  497. With TPReq(GlobalReqBuf)^
  498.  do Begin
  499.     func:= $6B;
  500.     _QueueObjId:= LSwap(QueueObjId);
  501.     BufLen:=5;
  502.     End;
  503. F2SystemCall($17,Sizeof(Treq),SizeOf(Trep),result);
  504. IF result = 0
  505.  Then with QJobList, TPrep(GlobalReplyBuf)^
  506.        do Begin
  507.           JobCount:= Swap(_JobCount);
  508.           IF (JobCount > MaxQueueJobs)
  509.            Then JobCount:= MaxQueueJobs;
  510.           FOR i:= 1 TO JobCount
  511.            DO JobNbrs[i]:= Swap(_JobBuf[i]);
  512.           MaxJobs:=swap(_MaxJobs);
  513.           End;
  514. GetQueueJobList:= (result = 0);
  515. { Valid completion codes:
  516.   $00 Success
  517.   $96 Server Out Of Memory;
  518.   $9C Invalid Path;
  519.   $D0 Queue Error;
  520.   $D1 No Queue;
  521.   $D2 No Queue Server;
  522.   $D3 No Queue Rights;
  523.   $FC No Such Object;
  524.   $FE Server Bindery Locked;
  525.   $FF Bindery Failure. }
  526. End;
  527.  
  528. {F217/6C}
  529. FUNCTION ReadQueueJobEntry( QObjId: Longint;JobNbr: Word;
  530.                             VAR QJob: TQueueJobEntry): Boolean;
  531. { You need to be either a Q_USER, Q_OPERATOR or a Q_SERVER }
  532. Type TReq=Record
  533.           BufLen     : Word;
  534.           func       : Byte;
  535.           _QueueObjId: Longint;  {hi-lo}
  536.           _JobNumber : Word      {hi-lo}
  537.           End;
  538.      TRep=Record
  539.           buf   : TintJobStruct; { Unit INTERNAL type. To be converted }
  540.           End;
  541.      TPreq=^Treq;
  542.      TPrep=^Trep;
  543. Begin
  544. With TPReq(GlobalReqBuf)^
  545.  do Begin
  546.     Buflen:= 7;
  547.     func:= $6C;
  548.     _QueueObjId:= LSwap(QObjId);
  549.     _JobNumber:= Swap(JobNbr);
  550.     End;
  551. F2SystemCall($17,SizeOf(Treq),SizeOf(Trep),result);
  552. IF result= 0
  553.  Then with TPrep(GlobalReplyBuf)^
  554.        do Begin
  555.           ConvertQJE2ext(buf,QJob,True);
  556.           End;
  557. ReadQueueJobEntry:= result = 0;
  558. { Valid completion codes:
  559.   $00 Success
  560.   $96 Server Out Of Memory;
  561.   $D0 Queue Error;
  562.   $D1 No Queue;
  563.   $D2 No Queue Server;
  564.   $D3 No Queue Rights;
  565.   $D5 No Queue Job;
  566.   $FC No Such Object;
  567.   $FE Server Bindery Locked;
  568.   $FF Bindery Failure. }
  569. End;
  570.  
  571. {F217/6A}
  572. FUNCTION RemoveJobFromQueue( QObjId: Longint; JobNbr: Word): Boolean;
  573. { You need to be Q_OPERATOR or the Q_USER who queued the job }
  574. Type TReq=Record
  575.           BufLen:   Word;
  576.           func:     Byte;
  577.           _QueueObjId: Longint; {hi-lo}
  578.           _JobNumber:Word    {hi-lo}
  579.           End;
  580.      TPreq=^Treq;
  581. Begin
  582. With TPReq(GlobalReqBuf)^
  583.  do Begin
  584.     Buflen:= 7;
  585.     func:= $6A;
  586.     _QueueObjId:= LSwap(QObjId);
  587.     _JobNumber:= Swap(JobNbr);
  588.     End;
  589. F2SystemCall($17,SizeOf(Treq),0,result);
  590. RemoveJobFromQueue:= result = 0;
  591. { Valid completion codes:
  592.   $00 Success
  593.   $96 Server Out Of Memory;
  594.   $D0 Queue Error;
  595.   $D1 No Queue;
  596.   $D3 No Queue Rights;
  597.   $D5 No Queue Job;
  598.   $D6 No Job Rights;
  599.   $FE Server Bindery Locked;
  600.   $FF Bindery Failure. }
  601. End;
  602.  
  603.  
  604. {F217/69 [2.1x+]}
  605. Function StartQueueJob(QobjId:Longint;JobNbr:Word):Boolean;
  606. Type Treq=record
  607.           len    :Word;
  608.           subFunc:Byte;
  609.           _QobjId:Longint; {hi-lo}
  610.           _JobNbr:Word;    {hi-lo}
  611.           end;
  612.      TPreq=^Treq;
  613. Begin
  614. WITH TPreq(GlobalReqBuf)^
  615.  do begin
  616.     subFunc:=$69;
  617.     _QobjId:=Lswap(QobjID);
  618.     _JobNbr:=swap(JobNbr);
  619.     len:=SizeOf(Treq)-2;
  620.     end;
  621. F2SystemCall($17,SizeOf(Treq),0,result);
  622. StartQueueJob:=(result=0)
  623. { Valid completion codes:
  624.   $00 Success
  625.   $96 Server Out Of Memory;
  626.   $D0 Queue Error;
  627.   $D1 No Queue;
  628.   $D3 No Queue Rights;
  629.   $D5 No Queue Job;
  630.   $D6 No Job Rights;
  631.   $FE Server Bindery Locked;
  632.   $FF Bindery Failure. }
  633. end;
  634.  
  635.  
  636. {F217/6E [2.1x+]}
  637. Function ChangeQueueJobPosition(QobjId:Longint; JobNbr:Word;
  638.                                 NewJobPos:Byte              ):Boolean;
  639. { Q_OPERATOR only }
  640. Type Treq=record
  641.           len       :Word;
  642.           subFunc   :Byte;
  643.           _QobjId   :Longint; {hi-lo}
  644.           _JobNbr   :Word;    {hi-lo}
  645.           _NewJobPos:Byte;
  646.           end;
  647.      TPreq=^Treq;
  648. Begin
  649. WITH TPreq(GlobalReqBuf)^
  650.  do begin
  651.     subFunc:=$6E;
  652.     _QobjId:=Lswap(QobjId);
  653.     _JobNbr:=swap(JobNbr);
  654.     _NewJobPos:=NewJobPos;
  655.     len:=SizeOf(Treq)-2;
  656.     end;
  657. F2SystemCall($17,SizeOf(Treq),0,result);
  658. ChangeQueueJobPosition:=(result=0)
  659. { Valid completion codes:
  660.   $00 Success
  661.   $96 Server Out Of Memory;
  662.   $D0 Queue Error;
  663.   $D1 No Queue;
  664.   $D5 No Queue Job;
  665.   $D6 No Job Rights;
  666.   $FE Server Bindery Locked;
  667.   $FF Bindery Failure. }
  668. end;
  669.  
  670. {F217/6F [2.1x+]}
  671. Function AttachQueueServerToQueue(QobjId:Longint):Boolean;
  672. { Q_SERVERs only }
  673. Type Treq=record
  674.           len    :Word;
  675.           subFunc:Byte;
  676.           _QobjId:Longint; {hi-lo}
  677.           end;
  678.      TPreq=^Treq;
  679. Begin
  680. WITH TPreq(GlobalReqBuf)^
  681.  do begin
  682.     subFunc:=$6F;
  683.     _QobjId:=Lswap(QobjId);
  684.     len:=SizeOf(Treq)-2;
  685.     end;
  686. F2SystemCall($17,SizeOf(Treq),0,result);
  687. AttachQueueServerToQueue:=(result=0)
  688. { Valid completion codes:
  689.   $00 Success
  690.   $96 Server Out Of Memory;
  691.   $9C Invalid Path;
  692.   $D0 Queue Error;
  693.   $D1 No Queue;
  694.   $D2 No Queue Server;
  695.   $FE Server Bindery Locked;
  696.   $FF Bindery Failure. }
  697. end;
  698.  
  699.  
  700. {F217/70 [2.1x+]}
  701. Function DetachQueueServerFromQueue(QobjId:Longint):Boolean;
  702. { Q_SERVERs only }
  703. Type Treq=record
  704.           len    :Word;
  705.           subFunc:Byte;
  706.           _QobjId:Longint; {hi-lo}
  707.           end;
  708.      TPreq=^Treq;
  709. Begin
  710. WITH TPreq(GlobalReqBuf)^
  711.  do begin
  712.     subFunc:=$70;
  713.     _QobjId:=Lswap(QobjId);
  714.     len:=SizeOf(Treq)-2;
  715.     end;
  716. F2SystemCall($17,SizeOf(Treq),0,result);
  717. DetachQueueServerFromQueue:=(result=0)
  718. { Valid completion codes:
  719.   $00 Success
  720.   $96 Server Out Of Memory;
  721.   $9C Invalid Path;
  722.   $D0 Queue Error;
  723.   $D1 No Queue;
  724.   $D2 No Queue Server;
  725.   $FE Server Bindery Locked;
  726.   $FF Bindery Failure. }
  727. end;
  728.  
  729.  
  730. {F217/71 [2.1x+]}
  731. Function ServiceQueueJob(QobjID:Longint; JobType:Word;
  732.                                     Var QjobEntry:TQueueJobEntry):Boolean;
  733. { Q_SERVERs only }
  734. Type Treq=record
  735.           len     :Word;
  736.           subFunc :Byte;
  737.           _QobjId :Longint; {hi-lo}
  738.           _JobType:Word; {hi-lo}
  739.           end;
  740.      Trep=Record
  741.           _qje:TintJobStruct; { EXCEPT last two fields }
  742.           end;
  743.      TPreq=^Treq;
  744.      TPrep=^Trep;
  745. Begin
  746. WITH TPreq(GlobalReqBuf)^
  747.  do begin
  748.     subFunc:=$71;
  749.     _QobjId:=Lswap(QobjId);
  750.     _JobType:=swap(JobType);
  751.     len:=SizeOf(Treq)-2;
  752.     end;
  753. F2SystemCall($17,SizeOf(Treq),SizeOf(Trep)-50-152,result);
  754. With TPrep(GlobalReplyBuf)^
  755.  do begin
  756.     ConvertQJE2Ext(_qje,QjobEntry,false);
  757.     FillChar(QjobEntry.JobDescription,50,#$0);
  758.     FillChar(QjobEntry.ClientRecordArea,152,#$0);
  759.     { Use the ReadQueueJobEntry function to get job's
  760.       descriptionstring and clientRecordArea. }
  761.     end;
  762. ServiceQueueJob:=(result=0)
  763. { Valid completion codes:
  764.   $00 Success
  765.   $96 Server Out Of Memory;
  766.   $9C Invalid Path;
  767.   $D0 Queue Error;
  768.   $D1 No Queue;
  769.   $D3 No Queue Rights;
  770.   $D5 No Queue Job;
  771.   $D9 Connection not Queue Server;
  772.   $DA Queue Halted;
  773.   $FE Server Bindery Locked;
  774.   $FF Bindery Failure. }
  775. end;
  776.  
  777. {F217/72 [2.1x+]}
  778. Function FinishServicingQueueJob(QobjId:Longint;JobNbr:Word;
  779.                                  Charge:Longint             ):Boolean;
  780. { Q_SERVERs only }
  781. Type Treq=record
  782.           len    :Word;
  783.           subFunc:Byte;
  784.           _QobjId:Longint; {hi-lo}
  785.           _JobNbr:Word;    {hi-lo}
  786.           _Charge:Longint; {hi-lo}
  787.           end;
  788.      TPreq=^Treq;
  789. Begin
  790. WITH TPreq(GlobalReqBuf)^
  791.  do begin
  792.     subFunc:=$72;
  793.     _QobjId:=Lswap(QobjId);
  794.     _JobNbr:=swap(JobNbr);
  795.     _Charge:=Lswap(Charge);
  796.     len:=SizeOf(Treq)-2;
  797.     end;
  798. F2SystemCall($17,SizeOf(Treq),0,result);
  799. FinishServicingQueueJob:=(result=0)
  800. { Valid completion codes:
  801.   $00 Success
  802.   $96 Server Out Of Memory;
  803.   $D0 Queue Error;
  804.   $D1 No Queue;
  805.   $D6 No Job Rights; }
  806. end;
  807.  
  808. {F217/73 [2.1x+]}
  809. Function AbortServicingQueueJob(QobjId:Longint; JobNbr:Word):Boolean;
  810. Type Treq=record
  811.           len    :Word;
  812.           subFunc:Byte;
  813.           _QobjId:Longint; {hi-lo}
  814.           _JobNbr:Word;    {hi-lo}
  815.           end;
  816.      TPreq=^Treq;
  817. Begin
  818. WITH TPreq(GlobalReqBuf)^
  819.  do begin
  820.     subFunc:=$73;
  821.     _QobjId:=Lswap(QobjId);
  822.     _JobNbr:=swap(JobNbr);
  823.     len:=SizeOf(Treq)-2;
  824.     end;
  825. F2SystemCall($17,SizeOf(Treq),0,result);
  826. AbortServicingQueueJob:=(result=0)
  827. { Valid completion codes:
  828.   $00 Success
  829.   $96 Server Out Of Memory;
  830.   $D0 Queue Error;
  831.   $D1 No Queue;
  832.   $D6 No Job Rights;
  833.   $D9 Connection not Queue Server; }
  834. end;
  835.  
  836. {F217/74 [2.1x+]}
  837. Function ChangeToClientRights(QobjId:Longint;JobNbr:Word):Boolean;
  838. { Q_SERVERs servicing job only }
  839. Type Treq=record
  840.           len    :Word;
  841.           subFunc:Byte;
  842.           _QobjId:Longint; {hi-lo}
  843.           _JobNbr:Word;    {hi-lo}
  844.           end;
  845.      TPreq=^Treq;
  846. Begin
  847. WITH TPreq(GlobalReqBuf)^
  848.  do begin
  849.     subFunc:=$74;
  850.     _QobjId:=Lswap(QobjId);
  851.     _JobNbr:=swap(JobNbr);
  852.     len:=SizeOf(Treq)-2;
  853.     end;
  854. F2SystemCall($17,SizeOf(Treq),0,result);
  855. ChangeToClientRights:=(result=0)
  856. { Valid completion codes:
  857.   $00 Success
  858.   $96 Server Out Of Memory;
  859.   $D0 Queue Error;
  860.   $D1 No Queue;
  861.   $D6 No Job Rights;
  862.   $D9 Connection not Queue Server; }
  863. end;
  864.  
  865. {F217/75 [2.1x+]}
  866. Function RestoreQueueServerRights:Boolean;
  867. { Q_SERVERs, servicing job and having previously called
  868.   ChangeToClientRights only }
  869. Type Treq=record
  870.           len    :Word;
  871.           subFunc:Byte;
  872.           end;
  873.      TPreq=^Treq;
  874. Begin
  875. WITH TPreq(GlobalReqBuf)^
  876.  do begin
  877.     subFunc:=$75;
  878.     len:=SizeOf(Treq)-2;
  879.     end;
  880. F2SystemCall($17,SizeOf(Treq),0,result);
  881. RestoreQueueServerRights:=(result=0)
  882. { Valid completion codes:
  883.   $00 Success
  884.   $96 Server Out Of Memory;
  885.   $9C Invalid Path;
  886.   $D0 Queue Error;
  887.   $D1 No Queue;
  888.   $D3 No Queue Rights;
  889.   $D5 No Queue Job;
  890.   $D9 Connection not Queue Server;
  891.   $DA Queue Halted;
  892.   $FE Server Bindery Locked;
  893.   $FF Bindery Failure. }
  894. end;
  895.  
  896. {F217/76 [2.1x+]}
  897. Function ReadQueueServerStatus(QobjId        :Longint;
  898.                                QserverObjId  :Longint;
  899.                                QserverConnNbr:Byte;
  900.                            Var Qstatus:TQueueServerStatus):Boolean;
  901. Type Treq=record
  902.           len       :Word;
  903.           subFunc   :Byte;
  904.           _QobjId   :Longint; {hi-lo}
  905.           _QSobjId  :Longint; {hi-lo}
  906.           _QSconnNbr:Byte;
  907.           end;
  908.      Trep=record
  909.           _Qstatus:TqueueServerStatus;
  910.           end;
  911.      TPreq=^Treq;
  912.      TPrep=^Trep;
  913. Begin
  914. WITH TPreq(GlobalReqBuf)^
  915.  do begin
  916.     subFunc:=$76;
  917.     _QobjId:=Lswap(QobjId);
  918.     _QSobjId:=Lswap(QserverObjId);
  919.     _QSconnNbr:=QserverConnNbr;
  920.     len:=SizeOf(Treq)-2;
  921.     end;
  922. F2SystemCall($17,SizeOf(Treq),SizeOf(Trep),result);
  923. With TPrep(GlobalReplyBuf)^
  924.  do begin
  925.     Move(_Qstatus,Qstatus,SizeOf(TQueueServerStatus));
  926.     end;
  927. ReadQueueServerStatus:=(result=0)
  928. { Valid completion codes:
  929.   $00 Success
  930.   $96 Server Out Of Memory;
  931.   $9C Invalid Path;
  932.   $D1 No Queue;
  933.   $D2 No Queue Server;
  934.   $D3 No Queue Rights;
  935.   $F1 Invalid Bindery Security;
  936.   $FC No Such Object;
  937.   $FE Server Bindery Locked;
  938.   $FF Bindery Failure. }
  939. end;
  940.  
  941. {F217/77 [2.1x+]}
  942. Function SetQueueServerStatus(QobjId:Longint; Qstatus:TqueueServerStatus):Boolean;
  943. Type Treq=record
  944.           len     :Word;
  945.           subFunc :Byte;
  946.           _QobjId :Longint; {hi-lo}
  947.           _Qstatus:TQueueServerStatus;
  948.           end;
  949.      TPreq=^Treq;
  950. Begin
  951. WITH TPreq(GlobalReqBuf)^
  952.  do begin
  953.     subFunc:=$77;
  954.     _QobjId:=Lswap(QobjId);
  955.     Move(Qstatus,_Qstatus,Sizeof(TQueueServerStatus));
  956.     len:=SizeOf(Treq)-2;
  957.     end;
  958. F2SystemCall($17,SizeOf(Treq),0,result);
  959. SetQueueServerStatus:=(result=0)
  960. { Valid completion codes:
  961.   $00 Success
  962.   $96 Server Out Of Memory;
  963.   $9C Invalid Path;
  964.   $D0 Queue Error;
  965.   $D1 No Queue;
  966.   $FE Server Bindery Locked;
  967.   $FF Bindery Failure. }
  968. end;
  969.  
  970. {F217/78 [2.1x+]}
  971. Function GetQueueJobsFileSize(QobjId:Longint; JobNbr:Word;
  972.                              Var JobSize:Longint          ):Boolean;
  973. Type Treq=record
  974.           len    :Word;
  975.           subFunc:Byte;
  976.           _QobjId:Longint; {hi-lo}
  977.           _JobNbr:Word;    {hi-lo}
  978.           end;
  979.      Trep=record
  980.           _QobjId :Longint; {hi-lo}
  981.           _JobNbr :Word;    {hi-lo}
  982.           _JobSize:Longint; {hi-lo}
  983.           end;
  984.      TPreq=^Treq;
  985.      TPrep=^Trep;
  986. Begin
  987. WITH TPreq(GlobalReqBuf)^
  988.  do begin
  989.     subFunc:=$78;
  990.     _QobjId:=Lswap(QobjId);
  991.     _JobNbr:=swap(JobNbr);
  992.     len:=SizeOf(Treq)-2;
  993.     end;
  994. F2SystemCall($17,SizeOf(Treq),SizeOf(Trep),result);
  995. With TPrep(GlobalReplyBuf)^
  996.  do begin
  997.     JobSize:=Lswap(_JobSize);
  998.     end;
  999. GetQueueJobsFileSize:=(result=0)
  1000. { Valid completion codes:
  1001.   $00 Success
  1002.   $96 Server Out Of Memory;
  1003.   $9C Invalid Path;
  1004.   $FE Server Bindery Locked;
  1005.   $FF Bindery Failure. }
  1006. end;
  1007.  
  1008.  
  1009. {F217/68 [2.1x+]}
  1010. Function CreateQueueJob(QobjId:Longint;
  1011.               {i/o} Var Qjob:TqueueJobEntry):Boolean;
  1012. Type Treq=record
  1013.           len    :Word;
  1014.           subFunc:Byte;
  1015.           _QobjId:Longint; {hi-lo}
  1016.           _Qjob  :TintJobStruct;
  1017.           end;
  1018.      Trep=record
  1019.           _QjobR:TintJobStruct; { Except the last two fields ! }
  1020.           end;
  1021.      TPreq=^Treq;
  1022.      TPrep=^Trep;
  1023. Begin
  1024. WITH TPreq(GlobalReqBuf)^
  1025.  do begin
  1026.     subFunc:=$68;
  1027.     _QobjId:=Lswap(QobjId);
  1028.     ConvertQJE2Int(Qjob,_Qjob);
  1029.     len:=SizeOf(Treq)-2;
  1030.     end;
  1031. F2SystemCall($17,SizeOf(Treq),SizeOf(Trep)-152-50,result);
  1032. With TPrep(GlobalReplyBuf)^
  1033.  do begin
  1034.     ConvertQJE2Ext(_QjobR,Qjob,False);
  1035.     { False => Last 2 fields remain unchanged }
  1036.     end;
  1037. CreateQueueJob:=(result=0)
  1038. { Valid completion codes:
  1039.   $00 Success
  1040.   $96 Server Out Of Memory;
  1041.   $99 Directory Full;
  1042.   $9C Invalid Path;
  1043.   $D0 Queue Error;
  1044.   $D1 No Queue;
  1045.   $D2 No Queue Server;
  1046.   $D3 No Queue Rights;
  1047.   $D4 Queue Full;
  1048.   $DA Queue Halted;
  1049.   $ED Property Already Exists;
  1050.   $EF Invalid Name;
  1051.   $F0 Wildcard Not Allowed;
  1052.   $F1 Invalid Bindery Security;
  1053.   $F7 No Property Create Privilege;
  1054.   $FC No Such Object;
  1055.   $FE Server Bindery Locked;
  1056.   $FF Bindery Failure. }
  1057. end;
  1058.  
  1059. {F217/6D [2.1x+]}
  1060. Function ChangeQueueJobEntry(QobjId:Longint;Qjob:TQueueJobEntry):Boolean;
  1061. Type Treq=record
  1062.           len    :Word;
  1063.           subFunc:Byte;
  1064.           _QobjId:Longint;      {hi-lo}
  1065.           _Qjob  :TintJobStruct;
  1066.           end;
  1067.      TPreq=^Treq;
  1068. Begin
  1069. WITH TPreq(GlobalReqBuf)^
  1070.  do begin
  1071.     subFunc:=$6D;
  1072.     _QobjId:=Lswap(QobjId);
  1073.     ConvertQJE2Int(Qjob,_Qjob);
  1074.     len:=SizeOf(Treq)-2;
  1075.     end;
  1076. F2SystemCall($17,SizeOf(Treq),0,result);
  1077. ChangeQueueJobEntry:=(result=0)
  1078. { Valid completion codes:
  1079.   $00 Success
  1080.   $96 Server Out Of Memory;
  1081.   $D0 Queue Error;
  1082.   $D1 No Queue;
  1083.   $D5 No Queue Job;
  1084.   $D7 Queue Servicing;
  1085.   $FE Server Bindery Locked;
  1086.   $FF Bindery Failure. }
  1087. end;
  1088.  
  1089.  
  1090. {$IFDEF Template} {--------------- Q unit function template ---------------}
  1091.  
  1092. {F217/ [2.1x+]}
  1093. Function (   ):Boolean;
  1094. Type Treq=record
  1095.           len:Word;
  1096.           subFunc:Byte;
  1097.  
  1098.           end;
  1099.      Trep=record
  1100.  
  1101.           end;
  1102.      TPreq=^Treq;
  1103.      TPrep=^Trep;
  1104. Begin
  1105. WITH TPreq(GlobalReqBuf)^
  1106.  do begin
  1107.     subFunc:=$
  1108.  
  1109.     len:=SizeOf(Treq)-2;
  1110.     end;
  1111. F2SystemCall($17,SizeOf(Treq),SizeOf(Trep),result);
  1112. With TPrep(GlobalReplyBuf)^
  1113.  do begin
  1114.  
  1115.     end;
  1116.   :=(result=0)
  1117. { Valid completion codes:
  1118.   $00 Success
  1119.   $96 Server Out Of Memory;
  1120.   $99 Drectory Full;
  1121.   $9B Bad Directory Handle;
  1122.   $9C Invalid Path;
  1123.   $D0 Queue Error;
  1124.   $D1 No Queue;
  1125.   $D2 No Queue Server;
  1126.   $D3 No Queue Rights;
  1127.   $D4 Queue Full;
  1128.   $D5 No Queue Job;
  1129.   $D6 No Job Rights;
  1130.   $D7 Queue Servicing;
  1131.   $D9 Connection not Queue Server;
  1132.   $DA Queue Halted;
  1133.   $DB Max Queue Servers;
  1134.   $ED Property Already Exists;
  1135.   $EE Object Already Exists;
  1136.   $EF Invalid Name;
  1137.   $F0 Wildcard Not Allowed;
  1138.   $F1 Invalid Bindery Security;
  1139.   $F5 No Object Create Privilege;
  1140.   $F7 No Property Create Privilege;
  1141.   $FC No Such Object;
  1142.   $FE Server Bindery Locked;
  1143.   $FF Bindery Failure.
  1144. }
  1145. end;
  1146.  
  1147. {$ENDIF}
  1148.  
  1149. end.
  1150.